//
//  XLUserInviteVC.m
//  XiangLove
//
//  Created by Dgh Hv on 2018/10/22.
//  Copyright © 2018年 BAOMIHUA.COM. All rights reserved.
//

#import "XLUserInviteVC.h"
#import "QQApiHandler.h"
#import "XLHomeViewModel.h"
#import "XLUserShareModel.h"

@interface XLUserInviteVC ()
@property (weak, nonatomic) IBOutlet UILabel *awardNum;
- (IBAction)didClickInviteButton:(id)sender;
@property (weak, nonatomic) IBOutlet UIButton *inviteButton;
@property (nonatomic, strong)XLHomeViewModel * viewModel;
@property (nonatomic, strong)XLUserShareModel * model;

@end

@implementation XLUserInviteVC

- (void)viewDidLoad {
    [super viewDidLoad];
    ViewRadius(self.inviteButton, 5);
    self.title = @"邀请好友";
    self.awardNum.text = self.awardNumber;
    [kNotificationCenter addObserver:self selector:@selector(shareSuccess) name:KQQShareSUCCESS object:nil];
    [self getData];
    // Do any additional setup after loading the view from its nib.
}

#pragma mark ----分享成功
-(void)shareSuccess
{
    kWeakSelf(self);
    [self.viewModel getAddWheelFortunComplete:^(BOOL isSuccess) {
        if(isSuccess)
        {
            [weakself getData];
        }
    }];
    
}

-(void)getData
{
    kWeakSelf(self);
    [self.viewModel getWheelRewardTotalComplete:^(XLUserShareModel *model) {
        weakself.model = model;
        weakself.awardNum.text = model.WheelTimes;
    }] ;
}


-(void)dealloc
{
    [kNotificationCenter removeObserver:self name:KQQShareSUCCESS object:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (IBAction)didClickInviteButton:(id)sender {
    if(self.model)
    {
        [QQApiHandler qqFriendsShareWithUrl:self.model.ShareUrl title:self.model.Title description:self.model.Content previewImageName:@"AppIcon"];
    }
}

-(XLHomeViewModel *)viewModel
{
    if(_viewModel == nil)
    {
        _viewModel = [[XLHomeViewModel alloc]init];
    }
    return _viewModel;
}

@end
